<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>办理材料寄送</title>
	    <base href="<%=basePath%>">
		<%@ include file="/main/main_css.jsp"%>
		<%@ include file="/main/main_js.jsp"%>
		<script type="text/javascript" src="static/js/jsAddress.js"></script>
		<script src="JS/main.js"></script>
		<script src="static/My97DatePicker/WdatePicker.js"></script>
  </head>
  
  <body>
  		<!--  -->
	<div class="all-wrapper">
		<div class="row com-header">
			<span>鹰潭市行政服务中心</span>
		</div>
		<div class="row main-content table-details">
		<div class="row" >
                <div class="time-count pull-right">
                   <span>剩余</span> <span id="date" class="text-red"></span> <span>秒</span>
                </div>
            </div>
		<div class="row">
                <h1>办理材料寄送（线上快递下单，线下快递员上门取件）</h1>
        </div>
			<div class="row">
				<div class="col-md-24">
					<h1>${uInfo.ITEMNAME }</h1>
				</div>
				<form id="myform"  class="form-horizontal"  action="material" method="post">
					
					<div class="row">
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">事项名称：</label>
								<div class="col-md-15">
									<input type="text" readonly="readonly"   name="register"
										value="${itemInfo.register }" class="form-control input-lg" />
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">寄件人姓名：</label>
								<div class="col-md-15">
									<input type="text" name="name"  id="name"
										value="${itemInfo.name }" class="form-control input-lg" />
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">手机号: </label>
								<div class="col-md-15">
									<input type="text"  name="phone"  id="phone"
										value="${itemInfo.phone }" class="form-control input-lg" />
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">省：</label>
								<div class="col-md-15">
									<select id="cmbProvince" name="cmbProvince" class="form-control input-lg"></select>
									<%-- <input type="text"  name="cmbProvince"
										value="${itemInfo.cmbProvince }" class="form-control input-lg" /> --%>
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">市：</label>
								<div class="col-md-15">
									<select id="cmbCity" name="cmbCity" class="form-control input-lg"></select>
									<%-- <input type="text"  name="cmbCity"
										value="${itemInfo.cmbCity }" class="form-control input-lg" /> --%>
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">区: </label>
								<div class="col-md-15">
									<select id="cmbArea" name="cmbArea" class="form-control input-lg"></select>
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">地址：</label>
								<div class="col-md-15">
									<input type="text"  name="address"   id="address"
										value="${itemInfo.address }" class="form-control input-lg" />
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7">邮政编码：</label>
								<div class="col-md-15">
									<input type="text"  name="yzbm"   id="yzbm"
										value="${itemInfo.yzbm }" class="form-control input-lg" />
								</div>
							</div>
						</div>
						<div class="col-md-12">
							<div class="form-group form-group-lg">
								<label class="control-label col-md-7" >预约快递员揽件时间：</label>
								<div class="col-md-15">
									<input id="time" name="time" class="Wdate form-control input-lg" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})">
								</div>
							</div>
						</div>
						<input type="hidden" name="prokeyid"  value="${prokeyid }">
					</div>
				</form>
			</div>
			

		</div>
		<div class="row footer">
			<a class="btn btn-success btn-lg" href="loginOut" role="button"><i
				class="fa fa-reply"></i>返回首页</a>
			<button class="btn btn-primary btn-lg" id="submit" >
				<i class="fa fa-hand-pointer-o"></i>快递下单
			</button>

		</div>
  		<form id="loginOut" action="loginOut"></form>
  </body>
  <script>
	//加入倒计时
	var count =  119;
	function countdown(){
		$("#date").text(count);
		if(count > 0){
			window.setTimeout("countdown()",1000);
			count --;
		}else{
			$("#loginOut").submit();
		}
	}
	countdown();
  
	//页面表单校验
	// 验证中文名称
	function isChinaName(name) {
		var pattern = /^[\u4E00-\u9FA5]{1,6}$/;
		return pattern.test(name);
	}
	
	// 验证手机号
	function isPhoneNo(phone) {
		var pattern = /^1[345678]\d{9}$/;
		return pattern.test(phone);
	}
	
	//验证邮编
	function isYzbm(yzbm){
		var pattern = /^[1-9][0-9]{5}$/;
		return pattern.test(yzbm);
	}
	
	// 验证函数
	function formValidate() {
		var str = '';

		// 判断名称
		if ($.trim($('#name').val()).length == 0) {
			str += '收件人姓名没有输入\n';
			$('#name').focus();
		} else {
			if (isChinaName($.trim($('#name').val())) == false) {
				str += '收件人名称不合法\n';
				$('#SJR').focus();
			}
		}

		// 判断手机号码
		if ($.trim($('#phone').val()).length == 0) {
			str += '手机号没有输入\n';
			$('#phone').focus();
		} else {
			if (isPhoneNo($.trim($('#phone').val())) == false) {
				str += '手机号码不正确\n';
				$('#SJH').focus();
			}
		}
		
		// 验证地址
		 if($.trim($('#address').val()).length == 0) { 
		  str += '地址没有输入\n';
		  $('#address').focus();
		 }
		
		//验证邮编
			if($.trim($('#yzbm').val()).length == 0){
				str += '邮政编码没有输入\n';
				$('#yzbm').focus();
			}else {
				if(isYzbm($.trim($('#yzbm').val())) == false){
					str +='邮政编码不正确\n';
					$('#yzbm').focus();
				}
			}
		//验证日期时间
		if($.trim($('#time').val()).length == 0) { 
		  str += '请选择揽件时间\n';
		  $('#time').focus();
		 }
		
		// 如果没有错误则提交
		if (str != '') {
			layer.alert(str);
			return false;
		} else {
			$('#myform').submit();
		}
	}
 
  //快递下单
  $('#submit').on('click', function() {
	  formValidate();
  });  
	
  	//页面加载动画
	var index = layer.load(3, {
	    shade: [0.3,'#000'] //0.1透明度的白色背景  
	});
	setTimeout(function(){
	    layer.close(index);
	},500);

	//省市区三级联动下拉框
	addressInit('cmbProvince', 'cmbCity', 'cmbArea');
	
	//绑定打开触摸板接口
	//修改寄件人姓名时调用
	$("#name").click(function() {
		var info = $("#name").val();
		var test = {
			'info' : info,
			'ispassword' : 0
		};
		var data = JSON.stringify(test);
		send_command("imewrite", data, function(receivedData) {
			var data = JSON.parse(receivedData);
			$("#name").val(data.msg);
		});
	});
	//修改手机号时调用
	$("#phone").click(function() {
		var info = $("#phone").val();
		var test = {
			'info' : info,
			'ispassword' : 0
		};
		var data = JSON.stringify(test);
		send_command("imewrite", data, function(receivedData) {
			var data = JSON.parse(receivedData);
			$("#phone").val(data.msg);
		});
	});
	//修改邮政编码时调用
	$("#yzbm").click(function() {
		var info = $("#yzbm").val();
		var test = {
			'info' : info,
			'ispassword' : 0
		};
		var data = JSON.stringify(test);
		send_command("imewrite", data, function(receivedData) {
			var data = JSON.parse(receivedData);
			$("#yzbm").val(data.msg);
		});
	});
	//修改收货地址时调用
	$("#address").click(function() {
		var info = $("#address").val();
		var test = {
			'info' : info,
			'ispassword' : 0
		};
		var data = JSON.stringify(test);
		send_command("imewrite", data, function(receivedData) {
			var data = JSON.parse(receivedData);
			$("#address").val(data.msg);
		});
	});
	var winH = $(document).height();
    var mainH = winH -170;
    $('.main-content').height(mainH);
</script>
</html>
